import { get, post, put, del } from "@/utils/http";
import type { CreateUserRequest, UpdateUserRequest, UserListResponse, UserResponse } from "@/types/user";

// 用户相关API
export const userApi = {
  // 获取用户列表
  getUsers: (params?: { page?: number; pageSize?: number; search?: string; gender?: number; roleId?: number }) =>
    get<UserListResponse>("/user/page", params),

  // 获取单个用户
  getUser: (id: string) => get<UserResponse>(`/user/${id}`),

  // 创建用户
  createUser: (data: CreateUserRequest) => post<UserResponse>("/user", data),

  // 更新用户
  updateUser: (id: string, data: UpdateUserRequest) => put<UserResponse>(`/user/${id}`, data),

  // 删除用户
  deleteUser: (id: string) => del<{ message: string }>(`/user/${id}`),
};
